<template>
  <div class="content-homesigle">
    <el-row
      type="flex"
      justify="start"
      class="single-back-multiple-wrap"
      style
      v-if="organizationId"
      v-show="backFlag"
    >
      <div class="iconfont icon-return return-btn" @click="backHomeFun" title="返回"></div>
      <p class="org-name">{{ organizationName }}</p>
    </el-row>
    <div class="content-homesigle-main-models" v-loading="loading">
      <div class="content-homeSinglleUnit-main-models" v-if="!homeFlag">
        <head-statistics class="content-item" :organizationId="organizationId"></head-statistics>
        <realtime-security-assessment class="content-item" :organizationId="organizationId" ref="realtimeSecurityAssessment"></realtime-security-assessment>
        <internet-monitor class="content-item" :organizationId="organizationId" ref="internetMonitor"></internet-monitor>
        <fire-fighting-system class="content-item" :organizationId="organizationId" ref="fireFightingSystem"></fire-fighting-system>
        <day-inspection class="content-item" :organizationId="organizationId" ref="dayInspection"></day-inspection>
        <hidden-danger-rectification class="content-item" :organizationId="organizationId" ref="hiddenDangerRectification"></hidden-danger-rectification>
        <maintenance-progress class="content-item" :organizationId="organizationId"></maintenance-progress>
      </div>
      <home-single
        v-if="homeFlag"
        :organizationId="organizationId"
        :organizationName="organizationName"
        ref="homeSingle"
      ></home-single>
    </div>
  </div>
</template>

<script>
import headStatistics from "./HeadStatistics"; // 头部统计
import realtimeSecurityAssessment from "./RealtimeSecurityAssessment"; // 实时安全评估
import internetMonitor from "./InternetMonitor"; // 物联网监测
import fireFightingSystem from "./FireFightingSystem"; // 消防系统实时运行情况
import dayInspection from "./DayInspection"; // 日常巡检
import hiddenDangerRectification from "./HiddenDangerRectification"; // 隐患整改
import maintenanceProgress from "./MaintenanceProgress"; // 隐患整改
import homeSingle from "../pageModel/HomeSingle";
export default {
  name: "HomeSinglleUnit",
  props: {
    organizationId: {
      default() {
        return undefined;
      }
    },
    organizationName: {
      default() {
        return "";
      }
    },
    backHomeFun: {
      type: Function,
      default() {
        return () => {};
      }
    }
  },
  components: {
    headStatistics,
    realtimeSecurityAssessment,
    internetMonitor,
    fireFightingSystem,
    dayInspection,
    hiddenDangerRectification,
    maintenanceProgress,
    homeSingle
  },
  data() {
    return {
      loading: false,
      homeFlag: false,
      backFlag: true
    };
  },
  created() {},
  methods: {
    getHomeSingFlag(flag) {
      let that = this;
      that.homeFlag = flag;
      that.backFlag = !flag;
    },
    // 处理单单位推送消息
    dealWithSingleWSData(type, data) {
      let that = this;
      let SingleMap = {
        "50100": "realtimeSecurityAssessment",
        "50240": "hiddenDangerRectification",
        "1002": "internetMonitor",
        "50230": "dayInspection",
      };
      if(type === 1002) {
        that.$nextTick(()=>{
          that.$refs["fireFightingSystem"].refreshModel();
        })
      }
      if (that.$refs[SingleMap[type]]) {
        // 更新/刷新对应模块
        that.$nextTick(()=>{
          that.$refs[SingleMap[type]].refreshModel();
        })
      }
    }
  }
};
</script>
<style lang="scss">
.content-homesigle {
  background-color: #fff;
  .single-back-multiple-wrap {
    width: 100%;
    height: 40px;
    line-height: 40px;
    font-size: 26px;
    .org-name {
      color: #4c6cd7;
      font-weight: bold;
    }
  }
  .el-input__inner {
    background-color: #f2f4f8;
  }
  .content-homesigle-main-models {
    margin: 0 auto;
    width: 1200px;
  }
  .content-homeSinglleUnit-main-models {
    .content-item {
      margin: 0 auto 40px;
    }
    .content-item-tittle {
      height: 31px;
      font-size: 24px;
      font-weight: 500;
      text-align: left;
      color: #5f6884;
      font-weight: bold;
    }
    .item-content-tittle {
      padding: 30px 0 0 20px;
      width: 100%;
      height: 61px;
      font-size: 20px;
      font-weight: 400;
      text-align: left;
      color: #8890ab;
    }
  }
}
</style>